from flask_sqlalchemy import SQLAlchemy
from datetime import datetime

db = SQLAlchemy()

class Style(db.Model):
    __tablename__ = 'style'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), unique=True)
    created_at = db.Column(db.DateTime, default=datetime.now)

class Platform(db.Model):
    __tablename__ = 'platform'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), unique=True)
    created_at = db.Column(db.DateTime, default=datetime.now)

class Status(db.Model):
    __tablename__ = 'status'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), unique=True)
    created_at = db.Column(db.DateTime, default=datetime.now)

class Info(db.Model):
    __tablename__ = 'info'
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100), nullable=False)
    url = db.Column(db.String(200))
    style_id = db.Column(db.Integer, db.ForeignKey('style.id'))
    word_count = db.Column(db.Integer)
    platform_id = db.Column(db.Integer, db.ForeignKey('platform.id'))
    status_id = db.Column(db.Integer, db.ForeignKey('status.id'))
    remark = db.Column(db.Text)
    
    style = db.relationship('Style', backref='infos')
    platform = db.relationship('Platform', backref='infos')
    status = db.relationship('Status', backref='infos')
    created_at = db.Column(db.DateTime, default=datetime.now)